import 'dart:convert';

void main() {
  //一个JSON格式的用户列表字符串
  String jsonStr='[{"name":"Jack"},{"name":"Rose"}]';
  //将JSON字符串转为Dart对象(此处是List)
  List items=json.decode(jsonStr);
  print(items);
  //输出第一个用户的姓名
  print(items[0]["name"]);

  jsonStr = '''
  {
    "name": "John Smith",
    "email": "john@example.com"
  }
  ''';
  Map<String, dynamic> user = json.decode(jsonStr);
  print(user);
  print('Howdy, ${user['name']}');
  print("${user['email']}");

}